package com.lrkj.payfee.controller;

import com.lrkj.common.annotation.Log;
import com.lrkj.common.core.controller.BaseController;
import com.lrkj.common.core.domain.AjaxResult;
import com.lrkj.common.core.page.TableDataInfo;
import com.lrkj.common.enums.BusinessType;
import com.lrkj.common.utils.poi.ExcelUtil;
import com.lrkj.payfee.domain.RequirePay;
import com.lrkj.payfee.service.IRequirePayService;
import com.lrkj.payfee.vo.RequirePayVo;
import com.lrkj.payfee.vo.RoomArrearageVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 催缴管理Controller
 *
 * @author yajun_ren
 * @date 2022-03-24
 */
@RestController
@RequestMapping("/payfee/requirePay")
@Api(tags = "催缴管理")
public class RequirePayController extends BaseController {
    @Autowired
    private IRequirePayService requirePayService;

    /**
     * 查询催缴管理列表
     */
    @ApiOperation(value = "查询催缴管理列表", notes = "查询催缴管理列表")
    @PreAuthorize("@ss.hasPermi('payfee:requirePay:list')")
    @GetMapping("/list")
    public TableDataInfo list(RequirePay requirePay) {
        startPage();
        this.changeParameter(requirePay.getParams());
        List<RequirePay> list = requirePayService.selectRequirePayList(requirePay);
        return getDataTable(list);
    }

    /**
     * 导出催缴管理列表
     */
    @ApiOperation(value = "导出催缴管理列表", notes = "导出催缴管理列表")
    @PreAuthorize("@ss.hasPermi('payfee:requirePay:export')")
    @Log(title = "催缴管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(RequirePay requirePay) {
        List<RequirePay> list = requirePayService.selectRequirePayList(requirePay);
        ExcelUtil<RequirePay> util = new ExcelUtil<RequirePay>(RequirePay.class);
        return util.exportExcel(list, "催缴管理数据");
    }

    /**
     * 获取催缴管理详细信息
     */
    @ApiOperation(value = "获取催缴管理详细信息", notes = "获取催缴管理详细信息")
    @PreAuthorize("@ss.hasPermi('payfee:requirePay:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return AjaxResult.success(requirePayService.selectRequirePayById(id));
    }

    /**
     * 新增催缴管理
     */
    @ApiOperation(value = "新增催缴管理", notes = "新增催缴管理")
    @PreAuthorize("@ss.hasPermi('payfee:requirePay:add')")
    @Log(title = "催缴管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RequirePay requirePay) {
        return toAjax(requirePayService.insertRequirePay(requirePay));
    }

    /**
     * 修改催缴管理
     */
    @ApiOperation(value = "修改催缴管理", notes = "修改催缴管理")
    @PreAuthorize("@ss.hasPermi('payfee:requirePay:edit')")
    @Log(title = "催缴管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RequirePay requirePay) {
        return toAjax(requirePayService.updateRequirePay(requirePay));
    }

    /**
     * 删除催缴管理
     */
    @ApiOperation(value = "删除催缴管理", notes = "删除催缴管理")
    @PreAuthorize("@ss.hasPermi('payfee:requirePay:remove')")
    @Log(title = "催缴管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(requirePayService.deleteRequirePayByIds(ids));
    }

    /**
     * 催缴账单按照房间汇总
     */
    @ApiOperation(value = "催缴账单按照房间汇总", notes = "催缴账单按照房间汇总")
    @GetMapping("/requireBillRommCensus")
    public TableDataInfo requireBillRommCensus(RequirePayVo requirePayVo) {
        startPage();
        this.changeParameter(requirePayVo.getParams());
        List<RequirePay> list = requirePayService.requireBillRommCensus(requirePayVo);
        return getDataTable(list);
    }


    /**
     * 查询房屋欠费列表
     */
    @ApiOperation(value = "查询房屋欠费列表", notes = "查询房屋欠费列表")
    @GetMapping("/roomArrearageList")
    public TableDataInfo roomArrearageList(RoomArrearageVo roomArrearageVo) {
        return getDataTable(requirePayService.roomArrearageList(roomArrearageVo));
    }


}
